#include<bits/stdc++.h>
using namespace std;
#define reg register
#define pow2(x) (1<<(x))
#define getc() getchar_unlocked()
#define putc(c) putchar_unlocked(c)
#define gcd(x,y) __gcd(x,y)
typedef long long lli;
inline int read(){reg int x=0;reg bool f=0;reg char c=getc();while(c<'0'||c>'9'){f=(c=='-');c=getc();}while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getc();}return f?-x:x;}
inline void write(reg int x){if(x==-2147483648){putc('-'),putc('2'),putc('1'),putc('4'),putc('7'),putc('4'),putc('8'),putc('3'),putc('6'),putc('4'),putc('8');return;}if(x<0){x=-x;putc('-');}static char i32_out[15];reg int top=0;do{i32_out[++top]=(x%10)^48;x/=10;}while(x);while(top){putc(i32_out[top--]);}}
int n,m,L,V,p[100005];
struct fenshu{
    lli fz,fm;
    fenshu(reg int x=0,reg int y=1):fz(x),fm(y){
    }
    bool operator<(fenshu o)const{
        return fz*o.fm<o.fz*fm;
    }
    bool operator<(int x)const{
        return fz<fm*x;
    }
    bool operator<=(fenshu o)const{
        return fz*o.fm<=o.fz*fm;
    }
    bool operator<=(int x)const{
        return fz<=fm*x;
    }
    bool operator>(fenshu o)const{
        return fz*o.fm>o.fz*fm;
    }
    bool operator>(int x)const{
        return fz>fm*x;
    }
    bool operator>=(fenshu o)const{
        return fz*o.fm>=o.fz*fm;
    }
    bool operator>=(int x)const{
        return fz>=fm*x;
    }
    fenshu operator+(int x)const{
        return fenshu(fz+x*fm,fm);
    }
    inline string toString(){
        return to_string(fz)+"/"+to_string(fm);
    }
};
struct car{
    int d,v,a,l,r;
    fenshu pos;
    bool tag;
}a[100005];
struct my_pir{
    int l,r;
    my_pir(reg int x,reg int y):l(x),r(y){
    }
    bool operator<(my_pir o)const{
        return this->r<o.r;
    }
};
vector<my_pir> vec;
inline bool cmp(car c,int &x){
    return c.pos+c.d<x;
}
inline bool cmp2(int &x,car c){
    return c.pos+c.d>x;
}
//upper:first TRUE or >
//lower:first FALSE or >=
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    reg int T=read();
    for(reg int _=0;_<T;++_){
        n=read();
        m=read();
        L=read();
        V=read();

        memset(a,0,sizeof(a));
        for(reg int i=1;i<=n;i++){
            reg lli x,y,g;
            a[i].d=read();
            a[i].v=read();
            a[i].a=read();
            if(a[i].a>=0&&a[i].v>V){
                a[i].pos.fz=-1;
            }else if((a[i].v>V&&a[i].a<0)||(a[i].a>0)){
                x=(lli)V*V-a[i].v*a[i].v;
                y=2*a[i].a;
                if(y<0){
                    y=-y;
                    x=-x;
                }
                g=gcd(x,y);
                x/=g;
                y/=g;

                a[i].pos.fz=x;
                a[i].pos.fm=y;
            }else{
                a[i].pos.fz=-114514;
            }
        }
        for(reg int i=1;i<=m;i++){
            p[i]=read();
        }
        vec.clear();
        reg int ans=0;
        for(reg int i=1,val,x;i<=n;i++){
            if(a[i].pos.fz==-1){
                val=lower_bound(p+1,p+m+1,a[i].d)-p;
                if(val<=m){
                    ans++;
                    a[i].tag=1;
                    vec.emplace_back(val,m);
                }
            }else if(a[i].pos.fz>0){
                if(a[i].v>V){//a<0
                    x=lower_bound(p+1,p+m+1,a[i].d)-p;
                    if(x<=m&&(a[i].pos+a[i].d)>p[x]){
                        ++ans;
                        val=lower_bound(p+1,p+m+1,a[i],cmp2)-p-1;
                        vec.emplace_back(x,max(x,val));
                    }
                }else{//a[i].v<=V
                    if(a[i].a>0){
                        val=upper_bound(p+1,p+m+1,a[i],cmp)-p;
                        if(val<=m){
                            ++ans;
                            a[i].tag=1;
                            vec.emplace_back(val,m);
                        }
                    }
                }
            }
        }
        write(ans);
        putc(' ');
        priority_queue<my_pir>q;
        sort(vec.begin(),vec.end());
        if(!vec.size()){
            ans=0;
        }else{
            ans=1;
            q.emplace(vec[0]);
            for(reg int i=1,maxi=vec.size();i<maxi;i++){
                my_pir top=q.top();
                if(top.r<vec[i].l){
                    ++ans;
                    q.emplace(vec[i]);
                }
            }
        }
        write(m-ans);
        putc('\n');
    }
    return 0;
}
